//导入工具包
var gulp = require('gulp'),
	less = require('gulp-less'),
	rename = require('gulp-rename'),
    cleanCss = require('gulp-clean-css'),
	autoprefixer = require('gulp-autoprefixer');

// 编译less 压缩less
gulp.task('testLess', function () {
    return gulp.src('src/less/app.less')
        .pipe(less())
        .pipe(cleanCss())
        .pipe(autoprefixer({
            browsers: ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'],
            cascade: true, //是否美化属性值
            remove:true //是否去掉不必要的前缀 默认：true
        }))
        .pipe(rename('app.css'))
        .pipe(gulp.dest('dist/css'));
});

// 实时编译less
gulp.task('watch',function(){
  gulp.watch('src/less/*.less',['testLess']);
});
